package com.sky.mapper;

import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ShoppingMapper {

    /**
     * 查询queryshoppingCart对象所有的数据封装成列表
     * @param queryshoppingCart
     * @return
     */
    List<ShoppingCart> selectByAll(ShoppingCart queryshoppingCart);

    /**
     * 购物车新增数据
     * @param queryshoppingCart
     */
    void insertShoppingCart(ShoppingCart queryshoppingCart);

    /**
     * 更新购物车数据
     * @param dbshoppingCart
     */
    @Update("update shopping_cart set number = #{number}\n" +
            "where id = #{id};")
    void updateShoppingById(ShoppingCart dbshoppingCart);

    @Delete("delete from shopping_cart where user_id = #{userId}")
    void deleteByUserId(Long currentId);

    /**
     * 批量插入购物车数据
     *
     * @param shoppingCartList
     */
    void insertBatch(List<ShoppingCart> shoppingCartList);
}
